use axum::{
    http::StatusCode,
    response::{IntoResponse, Response},
};
use serde::Serialize;

use crate::server::{header, Cbor};

use super::{make_response, };

impl<T: Serialize> IntoResponse for Cbor<T> {
    fn into_response(self) -> Response {
        make_response(|| {
            let mut resp = serde_cbor::to_vec(&self.0)?.into_response();
            *resp.status_mut() = StatusCode::OK;
            resp.headers_mut().insert(header::API_RESP, header::VAL_API_OK);
            Ok(resp)
        })
    }
}
